var onLine = navigator.onLine;

$(document).on("pageinit","#login_index",function(){
	var username = $.cookie("cookUser");
	var password = $.cookie("cookPass");
	/**
	 * 根据用户名显示密码
	 */
	if ($.trim(username).length != 0){
		$("#username").val(username);
		$("#password").val(password);
		$("#rememberPassword").attr('checked',true).checkboxradio('refresh');
	}
	
	$("#username").bind('keyup',function(){
		var userNow = $("#username").val();
		if(userNow == username){
			$("#password").val(password);
		}else{
			$("#password").val("");
		}
	});

	$("#login").bind('click',function() {
		var username = $("#username").val();
		var password = $("#password").val();
		if($.trim(username).length == 0){
			pMessage("用户名不能为空");
			$("#username").focus();
			return false;
		}
		if($.trim(password).length == 0){
			pMessage("密码不能为空");
			$("#password").focus();
			return false;
		} 
		$("#loginform").attr("action",ctx + "/webmobile/login");
		$("#loginform").submit();
	});
});